//
//  WYCBarCodeController.m
//  WYCweibo
//
//  Created by 魏云超 on 15/11/11.
//  Copyright (c) 2015年 魏云超. All rights reserved.
//

#import "WYCBarCodeController.h"

@interface WYCBarCodeController ()
- (IBAction)close:(id)sender;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topCons;
@property (nonatomic, strong) CADisplayLink *link;
@end

@implementation WYCBarCodeController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
    //    [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
    self.link = link;
}
-(void)viewWillAppear:(BOOL)animated
{
    //开启定时器
    [self.link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
}
-(void)viewWillDisappear:(BOOL)animated{
    [self.link removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
}
-(void)update{
    self.topCons.constant -= 1;
    if (self.topCons.constant <= -128) {
        self.topCons.constant = 128;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)close:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end
